package com.google.rui.utils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class JsonHelperUtils {
	public static  String getString(JSONObject obj, String key) {
		try {
			return obj.getString(key);
		} catch (JSONException e) {
			return "";
		}
	}
	
	public static boolean getBoolean(JSONObject obj, String key){
		try {
			return obj.getBoolean(key);
			
		} catch (JSONException e) {
			return false;
		}
	}
	
	public static int getInt(JSONObject obj, String key){
		try {
			return obj.getInt(key);
		} catch (JSONException e) {
			return 0;
		}
	}
	
	public static double getDouble(JSONObject obj,String key){
		try {
			return obj.getDouble(key);
		} catch (JSONException e) {
			return 0;
		}
	}
	
	public static long getLong(JSONObject obj,String key){
		try {
			return obj.getLong(key);
		} catch (JSONException e) {
			return 0;
		}
	}
	
	public static JSONObject getJsonObj(JSONObject obj,String key){
		try {
			return obj.getJSONObject(key);
		} catch (JSONException e) {
			return null;
		}
	}
	
	public static JSONArray getJsonArray(JSONObject obj,String key){
		try {
			return obj.getJSONArray(key);
		} catch (JSONException e) {
			return null;
		}
	}
	
}
